package com.zhilei;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

/**
 * 配置springboot的静态资源类
 *
 * @author 志磊
 * @serial 2027-09-19
 */
@Configuration
public class StaticResourceConfig extends WebMvcConfigurationSupport {

    /**
     * 生成静态资源映射
     *
     * @param registry
     */
    @Override
    protected void addResourceHandlers(ResourceHandlerRegistry registry) {
        // TODO 利用了拦截器的原理
        // TODO 静态资源路径，在本地的resources下
        registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/");
        // TODO 上传路径
        registry.addResourceHandler("/upload/**").addResourceLocations("file:D:/temp");
        super.addResourceHandlers(registry);
    }
}
